/*
 *
 * Copyright(c) 2010 Safelayer Secure Communications
 *
 * This is open source software, placed under the terms of the
 * GNU GENERAL PUBLIC LICENSE Version 3.
 * Please see: http://www.gnu.org/licenses/gpl-3.0.txt
 * 
 * Permission to use, copy, modify, and distribute this software
 * for any purpose and without fee is hereby granted, provided
 * that the above copyright notices appear in all copies and that
 * both the copyright notice and this permission notice appear in
 * supporting documentation.
 * 
 */
package com.neuralnoise.foaf.core;

import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.Resource;

/**
 * JabberId based smushing FOAF rule.
 * 
 * @author victor.martinez <swtp@safelayer.com>
 * 
 */
public class JabberIdRule extends Rule {

	private Property propertyJabberId;

	public JabberIdRule() {
		super("Jabber id");
		propertyJabberId = FOAFVocabulary.jabberID;
	}

	@Override
	public boolean equals(Resource resource1, Resource resource2) {
		if (!resource1.hasProperty(propertyJabberId) || !resource2.hasProperty(propertyJabberId))
			return false;
		
		String jabberId1 = resource1.getProperty(propertyJabberId).getLiteral().toString();
		String jabberId2 = resource2.getProperty(propertyJabberId).getLiteral().toString();
		return jabberId1.equals(jabberId2);
	}

	@Override
	public boolean isTrustEquals() {
		return true;
	}

}
